<?php 

namespace app\transfer\controller;

use app\transfer\controller\SpeechLogic;

class Speech {
    protected static $Request;

    function __construct() {
        self::$Request = request()->param();
    }

	/**
     * 获取说话人分离结果
     */
    public function getSeparate() {
        try {
            $fid = self::$Request['fid'];
            $num = self::$Request['num'];
            $SpeechLogic = new SpeechLogic();
            $res = $SpeechLogic->separateShowLogic($fid, $num);
            if ($res->isSuccess) {
                return resultArray(['data' => $res->data]);
            }
            return resultArray(['error' => $res->info]);
        } catch (Exception $e) {
            return resultArray(['error' => $e->getMessage()]);
        }
    }

    /**
     * 开始说话人分离
     */
    public function startSeparate() {
        try {
            $fid = self::$Request['fid'];
            $num = self::$Request['num'];
            $SpeechLogic = new SpeechLogic();
            $res = $SpeechLogic->startRoleSeparate($fid, $num);
            if ($res->isSuccess) {
                return resultArray(['data' => $res->data]);
            }
            return resultArray(['error' => $res->info]);
        } catch (Exception $e) {
            return resultArray(['error' => $e->getMessage()]);
        }
    }
}